<?php

namespace App\Console\Commands\Schedule;

use App\Service\Schedule\ScheduleService;
use Illuminate\Console\Command;

class SendScheduleUsersRemind extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'schedule:send_schedule_users_remind';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '排班提醒用户&上班提醒';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {

        // 排班修改提醒用户-上一个小时内有排班记录修改的用户
        $startTime = date('Y-m-d H:00:00', strtotime("-1 hours"));
        $endTime   = date('Y-m-d H:00:00');
        ScheduleService::scheduleChangeRemind($startTime, $endTime);

        // 上班提醒-提前12小时提醒要上班的用户
        $startTime = date('Y-m-d H:00:00', strtotime("+12 hours"));
        $endTime   = date('Y-m-d H:00:00', strtotime("+13 hours"));
        ScheduleService::scheduleStartWorkRemind($startTime, $endTime);
    }

}
